<template>
  <div class="page-container">
    <div class="page-content">
      <div class="panel-container">
        <div class="panel-content">
          <div class="panel-line space-between">
            <div class="panel-left">
              <el-radio-group v-model="tabActive" style="margin-right: 30px" size="mini" @change="handleTabChange">
                <el-radio-button v-for="item in tabList" :key="item.value" :label="item.value">{{ item.label }}({{ item.num }})</el-radio-button>
              </el-radio-group>
              <el-button class="show-search" type="text" @click="handleShowSearch">
                <span v-if="showSearch"> 收起搜索 </span>
                <span v-else> 展开搜索 </span>
                <i class="el-icon-arrow-down" :class="{ rotate: showSearch }"></i>
              </el-button>
            </div>
            <div class="panel-right">
              <el-button type="warning" @click="handleApplyList" size="mini">检索待申领数据</el-button>
              <el-button type="warning" @click="handleApply" size="mini">申领</el-button>
              <el-button type="primary" @click="handlePublish" size="mini">+ 发布</el-button>
            </div>
          </div>
          <!--搜索-->
          <SearchUiNew ref="SearchUiNew" style="margin-top: 10px" v-show="showSearch" :searchFormArr="searchFormArr" @searchParma="searchParma" @resetForm="handleResetForm"></SearchUiNew>
        </div>
      </div>
      <!--数据信息-->
      <div class="panel-container no-margin">
        <el-table stripe :data="dataList" size="mini" :header-cell-style="{ background: '#F5F5F5', color: '#000000' }" ref="table" style="width: 100%" @selection-change="handleSelectionChange" v-loading="dataListLoading">
          <el-table-column type="selection" align="center" fixed="left" width="55"> </el-table-column>
          <el-table-column align="center" fixed="left" header-align="center" label="信息标题" prop="title" width="200">
            <template slot-scope="scope">
              <a v-if="scope.row.power_sts === 3" target="_blank" class="asset-title" :href="`https://jituan.feijiu.net/info/${scope.row.number_id}.html`">
                <span class="red">{{ getTitlePrefix(scope) }}</span>
                {{ scope.row.title }}
              </a>
              <span v-else>
                <span class="red">{{ getTitlePrefix(scope) }}</span
                >{{ scope.row.title }}
              </span>
            </template>
          </el-table-column>
          <el-table-column align="center" header-align="center" label="详情内容" prop="desc" width="300">
            <template slot-scope="scope">
              {{ scope.row.desc.slice(0, 50) }}
              <span v-if="scope.row.desc.length > 50"> ... </span>
            </template>
          </el-table-column>
          <el-table-column align="center" header-align="center" label="联系电话" prop="user_phone">
            <template slot-scope="scope">
              {{ getPhones(scope) }}
            </template>
          </el-table-column>
          <el-table-column align="center" header-align="center" label="联系人" prop="user_name"></el-table-column>
          <el-table-column align="center" header-align="center" label="价值等级">
            <template slot-scope="scope"> {{ getValue(scope.row.value) }} </template>
          </el-table-column>
          <el-table-column align="center" header-align="center" label="状态">
            <template slot-scope="scope"> {{ getPowerSts(scope.row.power_sts) }} </template>
          </el-table-column>
          <el-table-column align="center" header-align="center" label="申领人" prop="accept_man_name"></el-table-column>
          <el-table-column align="center" v-if="tabActive === 3" header-align="center" label="发布人" prop="pub_user_name"></el-table-column>
          <el-table-column align="center" header-align="center" label="ID" prop="number_id"></el-table-column>
          <el-table-column v-if="tabActive === 2" align="center" header-align="center" label="采集时间" prop="craw_time" width="150"></el-table-column>
          <el-table-column v-else-if="tabActive === 3" align="center" header-align="center" label="发布时间" prop="feijiu_pub_time" width="150"></el-table-column>
          <el-table-column v-else-if="tabActive === 4" align="center" header-align="center" label="删除时间" prop="delete_time" width="150"></el-table-column>
          <el-table-column v-else-if="tabActive === ''" align="center" header-align="center" label="创建时间" prop="created_time" width="150"></el-table-column>
          <el-table-column align="center" header-align="center" label="信息来源">
            <template slot-scope="scope">
              {{ getSource(scope.row.source) }}
              <span v-if="scope.row.source === 6">-{{ scope.row.spider_source }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" fixed="right" header-align="center" label="操作" width="120">
            <template slot-scope="scope">
              <el-button type="text" @click="handleEdit(scope)">编辑</el-button>
              <el-button type="text" @click="handleDelete(scope)" :class="{ 'button-danger': scope.row.accept_man_id == '' || scope.row.accept_man_id === currentUserId }" v-if="scope.row.power_sts !== 4" :disabled="!(scope.row.accept_man_id == '' || scope.row.accept_man_id === currentUserId)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          small
          background
          :current-page="pageNumber"
          :page-size="pageSize"
          :page-sizes="[10, 20, 50, 100]"
          :total="pageTotal"
          @current-change="currentChangeHandle"
          @size-change="sizeChangeHandle"
          layout="total, sizes, prev, pager, next, jumper"
          style="margin-top: 20px; text-align: right"
        ></el-pagination>
        <div class="panel-line" style="margin-top: 20px">
          <el-button v-if="tabActive !== 4" type="danger" @click="handleDeleteAll" size="mini">整页删除</el-button>
          <el-button v-if="tabActive !== 4" type="danger" @click="handleDeleteMultiple" size="mini" :disabled="multipleDeleteDisable()">删除</el-button>
          <el-button v-if="tabActive === 3" type="warning" @click="handleReturn" size="mini" :disabled="multipleSelection.length === 0">撤回至待审核</el-button>
        </div>
      </div>
    </div>

    <!--  检索待申领数据 -->
    <el-dialog title="检索待申领数据" :visible.sync="showDialogApplyList" width="80%" top="5%">
      <DialogApplyList v-if="showDialogApplyList" :areaList="areaList" @close="showDialogApplyList = false" />
    </el-dialog>

    <!--  申领 -->
    <el-dialog title="申领" :visible.sync="showDialogApply">
      <DialogApply v-if="showDialogApply" :areaList="areaList" @close="showDialogApply = false" @success="handleApplySuccess" />
    </el-dialog>
  </div>
</template>

<script>
import { apiAssetList, apiAssetDel, apiAssetReturn } from '@/api/assetsPublic'
import DialogApply from './components/DialogApply.vue'
import DialogApplyList from './components/DialogApplyList.vue'

export default {
  name: 'AssetManagement',
  components: { DialogApply, DialogApplyList },
  data() {
    const searchList1 = ['is_lock', 'recommend', 'front_sts', 'source', 'value', 'cate', 'zone', 'accept_man_id', 'search', 'search_type', 'time']
    const searchList2 = ['is_lock', 'recommend', 'front_sts', 'source', 'value', 'cate', 'zone', 'accept_man_id', 'search', 'search_type', 'crawTime', 'time']
    const searchList3 = ['is_lock', 'recommend', 'front_sts', 'source', 'value', 'cate', 'zone', 'accept_man_id', 'search', 'search_type', 'pubTime', 'time']
    const searchList4 = ['is_lock', 'recommend', 'front_sts', 'source', 'value', 'cate', 'zone', 'accept_man_id', 'search', 'search_type', 'delTime', 'time']
    const paramsList1 = [
      'title',
      'desc',
      'user_name',
      'user_phone',
      'number_id',
      'company_name',
      'spider_source',
      'is_gt',
      'is_dj',
      'is_tj',
      'is_img',
      'is_video',
      'is_lock',
      'front_sts',
      'source',
      'value',
      'accept_man_id',
      'c1',
      'c2',
      'sheng_id',
      'shi_id',
      'zone_id',
      'start_time',
      'end_time',
      'is_area_choice',
    ]
    const paramsList2 = [
      'title',
      'desc',
      'user_name',
      'user_phone',
      'number_id',
      'company_name',
      'spider_source',
      'is_gt',
      'is_dj',
      'is_tj',
      'is_img',
      'is_video',
      'is_lock',
      'front_sts',
      'source',
      'value',
      'accept_man_id',
      'c1',
      'c2',
      'sheng_id',
      'shi_id',
      'zone_id',
      'start_time',
      'end_time',
      'is_area_choice',
      'craw_start_time',
      'craw_end_time',
    ]
    const paramsList3 = [
      'title',
      'desc',
      'user_name',
      'user_phone',
      'number_id',
      'company_name',
      'spider_source',
      'is_gt',
      'is_dj',
      'is_tj',
      'is_img',
      'is_video',
      'is_lock',
      'front_sts',
      'source',
      'value',
      'accept_man_id',
      'c1',
      'c2',
      'sheng_id',
      'shi_id',
      'zone_id',
      'start_time',
      'end_time',
      'is_area_choice',
      'pub_start_time',
      'pub_end_time',
    ]
    const paramsList4 = [
      'title',
      'desc',
      'user_name',
      'user_phone',
      'number_id',
      'company_name',
      'spider_source',
      'is_gt',
      'is_dj',
      'is_tj',
      'is_img',
      'is_video',
      'is_lock',
      'front_sts',
      'source',
      'value',
      'accept_man_id',
      'c1',
      'c2',
      'sheng_id',
      'shi_id',
      'zone_id',
      'start_time',
      'end_time',
      'is_area_choice',
      'del_start_time',
      'del_end_time',
    ]

    const powerStsList = [
      { value: 1, label: '待申领' },
      { value: 2, label: '待审核' },
      { value: 3, label: '已发布' },
      { value: 4, label: '已删除' },
    ]
    const valueList = [
      { value: 0, label: '全部' },
      { value: 1, label: '低' },
      { value: 2, label: '中' },
      { value: 3, label: '高' },
    ]
    const sourceList = [
      { value: 0, label: '全部' },
      { value: 1, label: '员工发布' },
      { value: 2, label: '社群' },
      { value: 3, label: '新媒体' },
      { value: 5, label: '独享公开' },
      { value: 6, label: 'AI采集' },
      { value: 7, label: '用户发布' },
    ]
    return {
      query: {},
      multipleSelection: [],
      powerStsList,
      valueList,
      sourceList,
      showDialogApply: false,
      showDialogApplyList: false,
      showSearch: false,
      tabActive: 2,
      tabList: [
        { value: 2, label: '待审核', num_name: 'power', num: 0, searchList: searchList2, paramsList: paramsList2 },
        { value: 3, label: '已发布', num_name: 'pub', num: 0, searchList: searchList3, paramsList: paramsList3 },
        { value: 4, label: '已删除', num_name: 'delete', num: 0, searchList: searchList4, paramsList: paramsList4 },
        { value: '', label: '全部', num_name: 'total', num: 0, searchList: searchList1, paramsList: paramsList1 },
      ],
      searchFormArr: [
        {
          fieldName: '锁定状态:',
          type: 'radioGroup',
          field: 'is_lock',
          hidden: false,
          width: '45%',
          option: [
            { value: 0, label: '全部' },
            { value: 1, label: '未锁定' },
            { value: 2, label: '已锁定' },
          ],
        },
        {
          fieldName: '推荐属性:',
          type: 'checkboxGroup',
          field: 'recommend',
          hidden: false,
          width: '45%',
          default: [],
          option: [
            { value: 'is_gt', label: '个体' },
            { value: 'is_dj', label: '独家' },
            { value: 'is_tj', label: '推荐' },
            { value: 'is_img', label: '图片' },
            { value: 'is_video', label: '视频' },
          ],
        },
        {
          fieldName: '前台状态:',
          type: 'radioGroup',
          field: 'front_sts',
          hidden: false,
          width: '45%',
          option: [
            { value: 0, label: '全部' },
            { value: 2, label: '处置中' },
            { value: 3, label: '已成交' },
            { value: 4, label: '已失效' },
          ],
        },
        {
          fieldName: '价值等级:',
          type: 'radioGroup',
          field: 'value',
          hidden: false,
          width: '45%',
          option: valueList,
        },
        {
          fieldName: '信息来源:',
          type: 'radioGroup',
          field: 'source',
          hidden: false,
          width: '100%',
          option: sourceList,
        },
        {
          fieldName: '分类:',
          type: 'cascader',
          field: 'cate',
          hidden: false,
          props: { value: 'num_id', label: 'name', checkStrictly: true },
          option: [],
        },
        {
          fieldName: '地区:',
          type: 'cascader',
          field: 'zone',
          hidden: false,
          props: { value: 'code', label: 'name', checkStrictly: true, multiple: 'true' },
          option: [],
        },
        {
          fieldName: '申领人:',
          type: 'select',
          field: 'accept_man_id',
          hidden: false,
          option: [],
          placeholder: '请选择',
        },
        {
          fieldName: '检索:',
          type: 'input',
          field: 'search',
          hidden: false,
          placeholder: '请输入检索',
        },
        {
          fieldName: '',
          type: 'select',
          field: 'search_type',
          hidden: false,
          labelWidth: '0px',
          default: 'title',
          clearable: false,
          option: [
            { value: 'title', label: '按标题' },
            { value: 'desc', label: '按内容' },
            { value: 'user_name', label: '按联系人' },
            { value: 'user_phone', label: '按联系电话' },
            { value: 'number_id', label: '按id' },
            { value: 'company_name', label: '按公司名称' },
            { value: 'spider_source', label: '按采集来源' },
          ],
          placeholder: '请选择',
        },
        {
          fieldName: '采集时间:',
          type: 'timePicker',
          field: 'crawTime',
          hidden: false,
          placeholder: '请选择采集时间',
          timeType: 'daterange',
          format: 'yyyy-MM-dd',
        },
        {
          fieldName: '发布时间:',
          type: 'timePicker',
          field: 'pubTime',
          hidden: false,
          placeholder: '请选择发布时间',
          timeType: 'daterange',
          format: 'yyyy-MM-dd',
        },
        {
          fieldName: '删除时间:',
          type: 'timePicker',
          field: 'delTime',
          hidden: false,
          placeholder: '请选择删除时间',
          timeType: 'daterange',
          format: 'yyyy-MM-dd',
        },
        {
          fieldName: '创建时间:',
          type: 'timePicker',
          field: 'time',
          hidden: false,
          placeholder: '请选择创建时间',
          timeType: 'daterange',
          format: 'yyyy-MM-dd',
        },
      ],
      searchParams: {
        title: '',
        desc: '',
        user_name: '',
        user_phone: '',
        number_id: '',
        company_name: '',
        spider_source: '',
        is_gt: '',
        is_dj: '',
        is_tj: '',
        is_img: '',
        is_video: '',
        is_lock: '',
        front_sts: '',
        source: '',
        value: '',
        accept_man_id: '',
        c1: '',
        c2: '',
        sheng_id: [],
        shi_id: [],
        zone_id: [],
        start_time: '',
        end_time: '',
        is_area_choice: '',
        craw_start_time: '',
        craw_end_time: '',
        del_start_time: '',
        del_end_time: '',
        pub_start_time: '',
        pub_end_time: '',
      },
      dataList: [],
      pageNumber: 1,
      pageSize: 10,
      pageTotal: 0,
      dataListLoading: false,
      areaList: [],
      areaDefault: [],
      currentUserId: '',
    }
  },
  activated() {
    this.$refs.table.doLayout()
  },
  mounted() {
    this.init()
    this.$bus.$on('assetsPublicListUpdate', this.getDataList)
  },
  destroyed() {
    this.$bus.$off('assetsPublicListUpdate', this.getDataList)
  },
  methods: {
    // 初始化
    init() {
      this.getSelectList()
      this.query = this.$route.query
      const { phone, start_time, end_time, tab, apply } = this.query
      if (tab !== undefined) {
        this.tabActive = tab
      }
      this.searchFormChange()
      apply && (this.showDialogApply = true)
      if (phone) {
        this.showSearch = true
        this.searchParams.user_phone = phone
      }
      if (start_time && end_time) {
        this.showSearch = true
        this.searchParams.start_time = start_time
        this.searchParams.end_time = end_time
      }

      this.currentUserId = localStorage.getItem('feijiu_user_id')
      // 待审核状态默认查询当前登录人=》改成全部状态=》改成不默认选中
      // if (Object.keys(this.query).length === 0) {
      //   if (this.currentUserId) {
      //     this.searchParams.accept_man_id = this.currentUserId
      //   }
      // }
      this.$nextTick(() => {
        const setItemList = []
        if (phone) {
          setItemList.push({ key: 'search', value: phone })
          setItemList.push({ key: 'search_type', value: 'user_phone' })
        }

        if (start_time && end_time) {
          setItemList.push({ key: 'time', value: [start_time, end_time] })
        }
        // 待审核默认查询当前登录人=》改成全部状态=》改成不默认选中
        // if (Object.keys(this.query).length === 0) {
        //   setItemList.push({ key: 'accept_man_id', value: this.currentUserId })
        // }
        if (setItemList.length > 0) {
          this.$refs.SearchUiNew.setItemValue(setItemList)
        } else {
          this.getDataList()
        }
      })
    },
    handleShowSearch() {
      this.showSearch = !this.showSearch
    },
    searchFormChange() {
      const showList = this.tabList.find((item) => item.value === this.tabActive).searchList
      this.searchFormArr.forEach((item) => {
        if (showList.includes(item.field)) {
          item.hidden = false
        } else {
          item.hidden = true
        }
      })
    },
    // 获取下拉数据
    getSelectList() {
      this.$store.dispatch('select/getCateList').then((res) => {
        const formItem = this.searchFormArr.find((item) => item.field === 'cate')
        formItem.option = res
      })

      this.$store.dispatch('select/getCityList').then((res) => {
        const formItem = this.searchFormArr.find((item) => item.field === 'zone')
        this.areaList = formItem.option = [
          {
            code: -1,
            name: '未分配地区',
          },
          {
            code: -2,
            name: '全国',
          },
          ...res,
        ]
      })

      this.$store.dispatch('select/getUserList').then((res) => {
        const formItem = this.searchFormArr.find((item) => item.field === 'accept_man_id')
        formItem.option = res
      })
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true
      let info = { pageNumber: this.pageNumber, pageSize: this.pageSize, power_sts: this.tabActive }
      const paramsList = this.tabList.find((item) => item.value === this.tabActive).paramsList
      paramsList.forEach((item) => {
        info[item] = this.searchParams[item]
      })
      apiAssetList(info)
        .then((res) => {
          const { data, total, others } = res
          this.dataList = data
          this.pageTotal = total
          this.dataListLoading = false
          this.tabList.forEach((item) => {
            item.num = others[item.num_name]
          })
          this.$refs.table.doLayout()
        })
        .catch((e) => {
          this.dataList = []
          this.pageTotal = 0
          this.dataListLoading = false
        })
    },
    // 列表查询
    searchParma(e) {
      let list = ['recommend', 'cate', 'zone', 'search', 'search_type', 'time']
      this.searchFormArr.forEach((item) => {
        if (list.includes(item.field)) return
        if (e[item.field]) {
          this.searchParams[item.field] = e[item.field]
        } else {
          this.searchParams[item.field] = ''
        }
      })
      const formItem = this.searchFormArr.find((item) => item.field === 'recommend')
      const option = formItem.option
      option.forEach((item) => {
        if (e.recommend.includes(item.value)) {
          this.searchParams[item.value] = 1
        } else {
          this.searchParams[item.value] = ''
        }
      })
      if (e.cate) {
        this.searchParams.c1 = e.cate[0] || ''
        this.searchParams.c2 = e.cate[1] || ''
      } else {
        this.searchParams.c1 = this.searchParams.c2 = ''
      }
      if (e.zone) {
        this.areaDefault = e.zone
        this.searchParams.sheng_id = []
        this.searchParams.shi_id = []
        this.searchParams.zone_id = []
        this.searchParams.is_area_choice = 0
        let all = false
        e.zone.forEach((item) => {
          if (item[0] === -2) {
            // 全国
            all = true
          } else if (item[0] === -1) {
            // 未分配地区
            this.searchParams.is_area_choice = 1
          } else {
            const length = item.length
            if (length === 1) {
              this.searchParams.sheng_id.push(item[0])
            } else if (length === 2) {
              this.searchParams.shi_id.push(item[1])
            } else if (length === 3) {
              this.searchParams.zone_id.push(item[2])
            }
          }
        })
        if (all) {
          this.searchParams.sheng_id = []
          this.searchParams.shi_id = []
          this.searchParams.zone_id = []
          this.searchParams.is_area_choice = 0
        }
      } else {
        this.searchParams.sheng_id = this.searchParams.shi_id = this.searchParams.zone_id = []
      }
      const formItem1 = this.searchFormArr.find((item) => item.field === 'search_type')
      const option1 = formItem1.option
      option1.forEach((item) => {
        this.searchParams[item.value] = ''
      })
      if (e.search) {
        this.searchParams[e.search_type] = e.search
        // 优化需求2024-11-1：点查询的时候如果检索框有内容就自动选中【已发布】，如果想看另外的状态就再切一下状态
        this.tabActive = 3
      }
      if (e.crawTime) {
        this.searchParams.craw_start_time = e.crawTime[0]
        this.searchParams.craw_end_time = e.crawTime[1]
      } else {
        this.searchParams.craw_start_time = this.searchParams.craw_end_time = ''
      }
      if (e.pubTime) {
        this.searchParams.pub_start_time = e.pubTime[0]
        this.searchParams.pub_end_time = e.pubTime[1]
      } else {
        this.searchParams.pub_start_time = this.searchParams.pub_end_time = ''
      }
      if (e.delTime) {
        this.searchParams.del_start_time = e.delTime[0]
        this.searchParams.del_end_time = e.delTime[1]
      } else {
        this.searchParams.del_start_time = this.searchParams.del_end_time = ''
      }
      if (e.time) {
        this.searchParams.start_time = e.time[0]
        this.searchParams.end_time = e.time[1]
      } else {
        this.searchParams.start_time = this.searchParams.end_time = ''
      }
      this.pageNumber = 1
      this.getDataList()
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageNumber = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageNumber = val
      this.getDataList()
    },
    // 切换tab
    handleTabChange() {
      this.searchFormChange()
      this.pageNumber = 1
      this.getDataList()
    },
    // 编辑
    handleEdit(scope) {
      this.$store.dispatch('permission/routeAuthorization', 'AssetPublish').then((res) => {
        let info = { pageNumber: this.pageNumber, pageSize: this.pageSize, power_sts: this.tabActive }
        const paramsList = this.tabList.find((item) => item.value === this.tabActive).paramsList
        paramsList.forEach((item) => {
          info[item] = this.searchParams[item]
        })
        info.position = scope.$index
        window.localStorage.setItem('asset-edit-table-query', JSON.stringify(info))
        // 新窗口打开
        let newWindow = window.open(`${location.origin}/#/assetsPublic/assetPublish?id=${scope.row.id}`)
      })
    },
    // 发布
    handlePublish() {
      // 强制刷新路由
      this.$store.dispatch('permission/routeAuthorization', 'AssetPublish').then((res) => {
        this.$bus.$emit('forceUpdate', 'AssetPublish')
        this.$router.push({
          path: '/assetsPublic/assetPublish',
        })
      })
    },
    // 删除
    handleDelete(scope) {
      this.assetDelete([scope.row.id])
    },
    // 申领
    handleApply() {
      this.showDialogApply = true
    },
    // 检索带申领数据
    handleApplyList() {
      this.showDialogApplyList = true
    },
    // 获取状态
    getPowerSts(value) {
      const item = this.powerStsList.find((item) => item.value === value)
      if (item) {
        return item.label
      } else {
        return ''
      }
    },
    // 获取价值
    getValue(value) {
      if (value === 0) {
        return ''
      }
      const item = this.valueList.find((item) => item.value === value)
      if (item) {
        return item.label
      } else {
        return ''
      }
    },
    // 获取来源
    getSource(value) {
      const item = this.sourceList.find((item) => item.value === value)
      if (item) {
        return item.label
      } else {
        return ''
      }
    },
    // 申领成功
    handleApplySuccess() {
      this.showDialogApply = false
      this.tabActive = 2
      this.getDataList()
    },
    // 表格多选
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    // 多选删除禁用
    multipleDeleteDisable() {
      if (this.multipleSelection.length === 0) {
        return true
      }
      let flag = 1
      this.multipleSelection.forEach((item) => {
        if (item.accept_man_id === '' || item.accept_man_id === this.currentUserId) {
          flag = 2
        }
      })
      if (flag === 1) {
        return true
      }
      return false
    },
    // 整页删除
    handleDeleteAll() {
      this.assetDelete(this.dataList.map((item) => item.id))
    },
    // 多选删除
    handleDeleteMultiple() {
      this.assetDelete(this.multipleSelection.map((item) => item.id))
    },

    // 多选撤回至待审核
    handleReturn() {
      window.enterPreventDefault = false
      const ids = this.multipleSelection.map((item) => item.id)
      this.$confirm('确定要撤回这些信息？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          window.enterPreventDefault = true
          this.dataListLoading = true
          apiAssetReturn({ ids })
            .then(() => {
              this.dataListLoading = false
              this.$message({
                type: 'success',
                message: '撤回成功!',
              })
              if (ids.length === this.dataList.length && this.tabActive === 3 && this.pageNumber > 1) {
                this.pageNumber--
              }
              this.getDataList()
            })
            .catch(() => {
              this.dataListLoading = false
            })
        })
        .catch(() => {
          window.enterPreventDefault = true
        })
    },
    // 删除
    assetDelete(ids) {
      window.enterPreventDefault = false
      this.$confirm('确定要删除这些信息？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          window.enterPreventDefault = true
          this.dataListLoading = true
          apiAssetDel({ ids, flag: this.tabActive === 2 ? 2 : 1 })
            .then(() => {
              this.dataListLoading = false
              this.$message({
                type: 'success',
                message: '删除成功!',
              })
              if (ids.length === this.dataList.length && (this.tabActive === 2 || this.tabActive === 3) && this.pageNumber > 1) {
                this.pageNumber--
              }
              this.getDataList()
            })
            .catch(() => {
              this.dataListLoading = false
            })
        })
        .catch(() => {
          window.enterPreventDefault = true
        })
    },
    // 联系方式
    getPhones(scope) {
      let list = []
      if (scope.row.user_phone) {
        list.push(scope.row.user_phone)
      }
      if (scope.row.user_tel) {
        list.push(scope.row.user_tel)
      }
      if (scope.row.other_ways) {
        list.push(scope.row.other_ways)
      }
      return list.join('、')
    },
    // 重置筛选
    handleResetForm() {
      this.searchParams.is_area_choice = ''
    },
    // 标题前缀
    getTitlePrefix(scope) {
      let prefix = [
        { value: 'is_dj', name: '独家' },
        { value: 'is_gt', name: '个体' },
        { value: 'is_tj', name: '推荐' },
        { value: 'is_img', name: '图' },
        { value: 'is_video', name: '视频' },
      ]
      let list = []
      prefix.forEach((item) => {
        if (scope.row[item.value]) {
          list.push(item.name)
        }
      })
      return list.join(' ') + ' '
    },
  },
}
</script>
<style lang="scss" scoped>
.asset-title {
  color: #409eff;
  cursor: pointer;
  &:hover {
    text-decoration: underline;
  }
}
.red {
  color: #f56c6c;
}
</style>
